<?php
class sfDeleteKTDSetupTask extends sfBaseTask {
       protected function configure(){
            $this->addOptions(array(
                new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The Application', 'frontend'),
                new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The Environment', 'prod'),
            ));
            $this->namespace = "setup";
            $this->name = "delete";
            $this->briefDescription = "Delete the setup directory (Use after the setup)";
            $this->detailedDescription = <<<EOF
            The [setup:delete|INFO] task deletes the setup dir from KTD:
            [./symfony setup:delete --env=prod |INFO]
EOF;
       }
       protected function execute($arguments = array(), $options = array()){
           $dir = sfConfig::get("sf_root_dir");
           $app = $options["application"];
           $setup = $dir.'/apps/'.$app.'/modules/setup';
           if(!is_dir($setup))
               $this->logSection ("Installation", sprintf("Le dossier d'installation n'existe pas ou plus dans le dossier %s", $setup));
           else{
              if(!unlink($setup.'/actions/actions.class.php')   ||
                 !unlink($setup.'/config/security.yml')         ||
                 !unlink($setup.'/config/view.yml')             ||
                 !unlink($setup.'/templates/indexSuccess.php')  ||
                 !unlink($setup.'/templates/finishSuccess.php')  ||

                 !rmdir($setup.'/actions')                      ||
                 !rmdir($setup.'/config')                       ||
                 !rmdir($setup.'/templates')                    ||
                 !rmdir($setup))
                  $this->logSection("Installation", sprintf("Le dossier d'installation a ete supprime avec succes !"));
              else
                  $this->logSection("Installation", sprintf("Echec de la suppression du dossier d'installation..."));
           }
       }
}